#include <windows.h>
#include <windowsx.h>
#include <commdlg.h>
#include <commctrl.h>
#include <tchar.h>
#include <cstdlib>

int SBOutputF(HWND hwSB,const char *szContent,...) {
	char bfrOut[400]={0},bfrTime[200]={0};
	va_list vars;
	va_start(vars,szContent);
	vsprintf(bfrOut,szContent,vars);
	va_end(vars);

	time_t ttm;
	tm stm;
	ttm=time(NULL);
	stm=*localtime(&ttm);
	sprintf(bfrTime,"[%d/%d/%d %02d:%02d:%02d] "
	        ,stm.tm_year+1900,stm.tm_mon+1,stm.tm_mday
	        ,stm.tm_hour,stm.tm_min,stm.tm_sec);

	strcat(bfrTime,bfrOut);

	return SendMessage(hwSB,SB_SETTEXT,0,(LPARAM)bfrTime);
}

int SetWindowTextF(HWND hwCtrl,const char *szContent,...){
	char bfrOut[400]={0};
	va_list vars;
	va_start(vars,szContent);
	vsprintf(bfrOut,szContent,vars);
	va_end(vars);
	return SetWindowText(hwCtrl,bfrOut);
}

int MessageBoxF(HWND hParent,UINT uFlags,const char *szTitle,const char *szContent,...){
	char bfrOut[400]={0};
	va_list vars;
	va_start(vars,szContent);
	vsprintf(bfrOut,szContent,vars);
	va_end(vars);
	return MessageBox(hParent,bfrOut,szTitle,uFlags);
}

int GetWindowTextF(HWND hwCtrl,const char *szFormat,...){
	char bfrGet[400]={0};
	GetWindowText(hwCtrl,bfrGet,400);
	va_list vars;
	va_start(vars,szFormat);
	vsscanf(bfrGet,szFormat,vars);
	va_end(vars);
}
